package org.opentcs.kcvehicle.communication.kc.udp.agv.param.function.read;

import org.opentcs.kcvehicle.communication.kc.common.byteutils.ByteUtils;

public class ReadRsp {
  //源数组
  private byte[] src;
  //ValueID ,4个字节
  public byte[] valueId;
  //应答数据总长度,2个字节
  public short valueByteLength;
  //预留,2个字节
  public byte[] reserved;
  //变量值,长度是 valueByteLength
  public byte[] dataValue;

  public ReadRsp(byte[] src) {
    this.src = src;
    this.valueId = ByteUtils.copyBytes(src, 0, 4);
    this.valueByteLength = ByteUtils.bytesToShort(ByteUtils.copyBytes(src, 4, 2), 1);
    this.reserved = ByteUtils.copyBytes(src, 6, 2);
    this.dataValue = ByteUtils.copyBytes(src, 8, valueByteLength - 8);
  }

  public boolean isOk() {
    if (valueByteLength <= 0) {
      return false;
    }
    else {
      return true;
    }
  }
}
